package com.qf.controller;


import com.qf.dao.PlaneSeatMapper;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.PlaneSeatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(value = "查看飞机票",tags = "查看飞机票")
@RestController
@RequestMapping(value = "/jp")
public class PSeatController {

    @Autowired
    PlaneSeatService planeSeatService;
     BaseResp baseResp=new BaseResp();

    //热度
    @ApiOperation("根据热度查飞机")
    @RequestMapping(value = "/findHeat",method = RequestMethod.GET)
     public BaseResp findHeat(Integer pid, Integer ppid) {
        List<PlaneSeatMapper> all = planeSeatService.findHeat(pid, ppid);
            baseResp.setData(all);
            baseResp.setCode(0);
             baseResp.setMsg("查询成功");
            return baseResp;

    }
     //根据两个地址查询全部机票
    @ApiOperation("根据行程查机票")
    @RequestMapping(value = "/findAllPlane",method = RequestMethod.POST)
    public  BaseResp findAllPlane(@RequestBody Map map){
        System.out.println(map);
        Object dispatureId = map.get("dispatureId");
        Object distinationId = map.get("distinationId");
        List<PlaneSeatMapper> allPlane = planeSeatService.findAllPlane(Integer.parseInt(dispatureId.toString()), Integer.parseInt(distinationId.toString()));
        baseResp.setCode(0);
        baseResp.setMsg("查询成功");
        baseResp.setData(allPlane);
        return baseResp;

    }
    //根据planeId查
    @ApiOperation("根据飞机id查飞机")
    @RequestMapping(value = "/findplane",method = RequestMethod.GET)
    public  BaseResp findAllPlane(@RequestParam("planeId") String pppid){
        List<PlaneSeatMapper> pppid1 = planeSeatService.findplane(pppid);
        baseResp.setCode(0);
        baseResp.setMsg("查询成功");
        baseResp.setData(pppid1);
        return baseResp;

    }


}

